package com.wwtech.epp.ui.adapter.work;

import android.support.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wwtech.epp.R;
import com.wwtech.epp.db.Friend;
import com.wwtech.epp.view.GlideCircleTransform;
import com.wwtech.epp.view.ProjectMemberView;

import java.util.ArrayList;

/**
 * Created by hu on 2017/9/1.
 */

public class ProjectAdapter extends BaseQuickAdapter<Friend, BaseViewHolder> {


    public ProjectAdapter(@Nullable ArrayList<Friend> data) {
        super(R.layout.project_member_layout, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, Friend friend) {
        ProjectMemberView projectMemberView = baseViewHolder.getView(R.id.memberView);
        baseViewHolder.addOnClickListener(R.id.memberView);
        if (friend.getUserId().equals("-1")) {
            projectMemberView.setSetInfo(false);
            projectMemberView.getAvaterImg().setImageDrawable(mContext.getResources().getDrawable(R.mipmap.work_add));
            projectMemberView.getNickTextview().setText("添加");
        } else if (friend.getUserId().equals("-2")) {
            //Glide.with(mContext)
//                .load(mContext.getResources().getIdentifier(item.getIcon(),"mipmap",mContext.getPackageName()))
//                    .into(imageView);

            projectMemberView.setSetInfo(false);
            projectMemberView.getAvaterImg().setImageDrawable(mContext.getResources().getDrawable(R.mipmap.delete_member));
            projectMemberView.getNickTextview().setText("删除");
        } else {
            projectMemberView.setSetInfo(true);
            Glide.with(mContext)
                    .load(friend.getAvatar())
                    .transform(new GlideCircleTransform(mContext))
                    .into(projectMemberView.getAvaterImg());
            projectMemberView.getNickTextview().setText(friend.getNickname());
        }
    }
}
